//定义命名空间
Namespace = {};
Namespace.register = function(fullNS) {
    // 将命名空间切成N部分, 比如Grandsoft、GEA等
    var nsArray = fullNS.split('.');
    var sEval = "";
    var sNS = "";
    for (var i = 0; i < nsArray.length; i++) {
        if (i != 0)
            sNS += ".";
        sNS += nsArray[i];
        // 依次创建构造命名空间对象（假如不存在的话）的语句
        // 比如先创建Grandsoft，然后创建Grandsoft.GEA，依次下去
        sEval += "if (typeof(" + sNS + ") == 'undefined') " + sNS + " = new Object();"
    }
    if (sEval != "")
        eval(sEval);
};
/*Loader Code*/
Namespace.register("Ace.Widget");
var A=Ace.Widget;
Ace.Widget= {
    _isLoaderMoudles:[],
    LoadMoudle: function(options) {
        var defaults=$.extend({
            Moudle:null,
            callback: function() {
            },
            depends:[]
        },options|| {});
        if(defaults.Moudle!=null) {
            //多个参数数组
            if(typeof(defaults.Moudle)=='Array') {
                for(var i=0,_length=defaults.Moudle.length;i<_length;i++) {
                    Ace.Widget.singleLoader(defaults.Moudle[i],defaults.callback);
                }
            } else {
                //单个参数
                Ace.Widget.singleLoader(defaults.Moudle,defaults.callback);
            }
        } else {
            alert("请指定要加载的模块");
        }
    },
    singleLoader: function(Moudle,callback) {
        var _moudle_name=Moudle;
        if(jQuery.inArray(_moudle_name,Ace.Widget._isLoaderMoudles)==-1) {     
            try {
                switch (_moudle_name) {
                    case "Ace.Widget.Top" :
                        LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_top.js', function () {
                            if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
								Ace.Widget._isLoaderMoudles.push(_moudle_name);
                                callback();
                                return false;
                            }
                        });
                        break;
                    case "Ace.Widget.Table":
                        LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_table.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                            if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                                callback();
                                return false;
                            }
                        });
                        break;
                    case "Ace.Widget.Cookie":
                        LazyLoad.js('http://static.aceona.com/app_js/jqueryUI/development-bundle/external/jquery.cookie.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                            if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                                callback();
                                return false;
                            }
                        });
                        break;
                 
                    case "Ace.Widget.Dialog":						
						LazyLoad.css('http://static.aceona.com/app_js/jqueryUI/css/custom-theme/jquery-ui-1.8rc3.custom.css');
					    if($("select").length>0){
							LazyLoad.js('http://static.aceona.com/app_js/jqueryUI/development-bundle/external/bgiframe/jquery.bgiframe.min.js');
						    
						}
						LazyLoad.js('http://static.aceona.com/app_js/jqueryUI/js/jquery-ui-1.8rc3.custom.min.js',function(){
							    Ace.Widget._isLoaderMoudles.push(_moudle_name);
								if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
									callback();
									return false;
								}
                        });
                        break;                  
                    case "Ace.Widget.jAlert":
                        LazyLoad.js('http://static.aceona.com/app_js/plugins_alerts/jquery.alerts.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                            LazyLoad.css('http://static.aceona.com/app_js/plugins_alerts/jquery.alerts.css');
                            if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                                callback();
                                return false;
                            }
                        });
                        break;
                    case "Ace.Widget.InputToggle":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_input.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.Validate":
                    LazyLoad.js('http://static.aceona.com/app_js/plugins_validate/jquery.validate.pack.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //城市类select控件--繁体版
                    case "Ace.Widget.Areazt":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/areazt.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //城市类select控件--简体版
                    case "Ace.Widget.Areazc":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/areazc.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //城市类select控件--英文版
                    case "Ace.Widget.Areaeu":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/areaeu.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //微博分享公用类函数
                    case "Ace.Widget.Weibo":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_tips_share.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //微博分享公用类函数
                    case "Ace.Widget.Copy":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/ZeroClipboard.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.Tips":
                    LazyLoad.js(['http://static.aceona.com/app_js/plugins_tips/jquery.tips.js','http://static.aceona.com/app_js/app_widgets/app_widgets_tips.js'], function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.DropList":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_drop.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.DropSearch":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_dropSearch.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.Validate":
                    LazyLoad.js('http://static.aceona.com/app_js/plugins_validate/jquery.validate.pack.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.tipsError":
					LazyLoad.css('http://static.aceona.com/app_js/components/tipError/tipError.css');
                    LazyLoad.js('http://static.aceona.com/app_js/components/tipError/tipError.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.MD5":
                    LazyLoad.js('http://static.aceona.com/app_js/md5.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
					case "Ace.Widget.Toggle":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_toggle.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
					case "Ace.Widget.LoadImage":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/jquery.lazyload.min.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    /*相册预览功能插件*/
                    case "Ace.Widget.FancyBox":
                    LazyLoad.css('http://static.aceona.com/app_js/plugins_fancybox/jquery.fancybox.css');
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/jquery.easing.js','http://static.aceona.com/app_js/app_widgets/jquery.mousewheel.js','http://static.aceona.com/app_js/plugins_fancybox/jquery.fancybox.js'], function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    /*loadding组件*/
                    case "Ace.Widget.Loading":
                    LazyLoad.js('http://static.aceona.com/app_js/app_widgets/app_widgets_loading.js', function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    case "Ace.Widget.Urchin":
                    LazyLoad.js(['http://static.aceona.com/js/urchin/urchin.js','http://static.aceona.com/js/urchin/urchin_common.js'], function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用工具类函数
                    case "Ace.Widget.Tools":
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/app_widgets_tools.js'], function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //mask js
                    case "Ace.Widget.Mask":
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/app_widgets_mask.js'], function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用textarea字数计算组件
                    case "Ace.Widget.Count":
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/app_widgets_count.js'], function () {
						Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用popup组件
                    case "Ace.Widget.Popup":
                    LazyLoad.js(['http://static.aceona.com/app_js/components/popup.js'], function () {
                        Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用选项卡组件
                    case "Ace.Widget.Tab":
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/app_widgets_tab.js'], function () {
                        Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用选项卡组件
                    case "Ace.Widget.Slider":
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/app_widgets_slide.js'], function () {
                        Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用广告切换组件
                    case "Ace.Widget.Ad":
               //     LazyLoad.css('http://static.aceona.com/app_css/app_ui_widgets.css');
                    LazyLoad.js([webRoot_path+'/app_js/app_widgets/app_widgets_ad.js'], function () {
                        Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                  //常用DatePicker组件
                    case "Ace.Widget.My97":
                    LazyLoad.js([webRoot_path + '/app_js/plugins_my97/WdatePicker.js'], function () {
                        Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                    //常用SlideArea动画组件
                    case "Ace.Widget.SlideArea":
                    LazyLoad.js(['http://static.aceona.com/app_js/app_widgets/app_widgets_slideArea.js'], function () {
                        Ace.Widget._isLoaderMoudles.push(_moudle_name);
                        if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
                            callback();
                            return false;
                        }
                    });
                    break;
                }
            } catch(e) {
                alert("Moulde传入的参数类型不对。");
            }
        } else {

			if(typeof(callback.constructor)=='function'&&callback.constructor==Function) {
  			             
						 callback();					
			         
		       
  }
      
			}
    }
}